#include "./Protocol.hpp"

class ProtocolLoginReq : public Protocol
{
public:
    ProtocolLoginReq()
        : Protocol(Type::LoginReq)
    {
    }

    virtual std::string serialize() override
    {
        Json::Value root;
        Json::FastWriter writer;
        root["type"] = _type;
        root["username"] = userid;
        root["password"] = password;

        return writer.write(root);
    }
    virtual void deserialize(const Json::Value& root) override
    {
        _type = (Protocol::Type)root["type"].asInt();
        userid = root["username"].asString();
        password = root["password"].asString();
    }

    std::string getUserid()
    {
        return userid;
    }

    std::string getPassword()
    {
        return password;
    }

    void setUserid(std::string username)
    {
        this->userid = username;
    }

    void setPassword(std::string password)
    {
        this->password = password;
    }

private:
    std::string userid;
    std::string password;
};


// class ProtocolLoginResp : public Protocol
// {
// public:
//     ProtocolLoginResp()
//         : Protocol(Type::LoginResp)
//     {
//     }

//     virtual std::string serialize() override
//     {
//         Json::Value root;
//         Json::FastWriter writer;
//         root["type"] = _type;
//         root["code"] = code;

//         return writer.write(root);
//     }
//     virtual void deserialize(const Json::Value& root) override
//     {
//         _type = (Protocol::Type)root["type"].asInt();
//         code = root["code"].asInt();
//     }

//     void setCode(int code)
//     {
//         this->code = code;
//     }

//     int getCode()
//     {
//         return code;
//     }
// private:
//     int  code;
// };